package net.ksic.common;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

public class PreferenceManager {

	public static String MY_PREFS = "MY_PREFS";
	public static String LOGIN_SESSIONKEY = "LOGIN_SEESIONKEY";
	public static String LOGIN_ID = "LOGIN_ID";
	public static String IS_AUTOLOGIN = "IS_AUTOLOGIN";

	int mode = Activity.MODE_PRIVATE;
	Context context;

	SharedPreferences mySharedPreferences;

	public PreferenceManager(Context context) {
		this.context = context;

		mySharedPreferences = this.context.getSharedPreferences(MY_PREFS, mode);
	}

	private void setSharedPreferences(String PreferenceType,
			String PreferenceValue) {

		SharedPreferences.Editor editor = this.mySharedPreferences.edit();

		editor.putString(PreferenceType, PreferenceValue);

		editor.commit();
	}

	private String getSharedPreferences(String PreferenceType) {
		return this.mySharedPreferences.getString(PreferenceType, "");
	}

	public void enableAutoLogin() {
		setSharedPreferences(IS_AUTOLOGIN, "true");
	}

	public void diableAutoLogin() {
		setSharedPreferences(IS_AUTOLOGIN, "false");
	}

	public String getAutoLogin() {
		return getSharedPreferences(IS_AUTOLOGIN);
	}

	public void setLoginSessionKey(String LoginSessionKey) {
		setSharedPreferences(LOGIN_SESSIONKEY, LoginSessionKey);
	}

	public String getLoginSessionKey() {
		return getSharedPreferences(LOGIN_SESSIONKEY);
	}

	public void setLoginId(String LoginId) {
		setSharedPreferences(LOGIN_ID, LoginId);
	}

	public String getLoginId() {
		return getSharedPreferences(LOGIN_ID);
	}
}
